Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Always run lint mode #1169

Closed
wants to merge 4 commits into from

Conversation

Frank-III
Copy link
Contributor

@Frank-III Frank-III commented Mar 4, 2025

I tried to follow what @suaviloquence did when he added lint_level to the query.

Some thoughts after taking more look into the issue:

  • should we introduce another field in the SemVerQuery called lint_mode which is an Enum to be either SemVer or AlwaysRun with default to be SemVer? Or should we encapsulate the required_update field into this LintMode enum since when lint_mode is AlwaysRun, RequiredSemverUpdate seems meaningless? I am still in favor of the 1st one for better DX but the second one is more clear?

  • We will run all need-to-run queries together, but when displaying the overall view should we seperate them? since before the category would be major/minor now we have always-run

example command output
       Built [   0.265s] (baseline)
     Parsing pub_api_sealed_trait_became_unconditionally_sealed v0.1.0 (baseline)
      Parsed [   0.001s] (baseline)
    Checking pub_api_sealed_trait_became_unconditionally_sealed v0.1.0 -> v0.1.0 (no change)
    Starting 148 checks, 0 unnecessary on 12 threads
        PASS [   0.002s]       major        attribute_proc_macro_missing
        PASS [   0.001s]       major        auto_trait_impl_removed
        PASS [   0.002s]       major        constructible_struct_adds_field
        PASS [   0.000s]       major        constructible_struct_adds_private_field
        PASS [   0.002s]       major        constructible_struct_changed_type
        PASS [   0.000s]       major        declarative_macro_missing
        PASS [   0.000s]       major        derive_helper_attr_removed
        PASS [   0.000s]       major        derive_proc_macro_missing
        PASS [   0.001s]       major        derive_trait_impl_removed
        PASS [   0.002s]       major        enum_discriminants_undefined_non_exhaustive_variant
        PASS [   0.000s]       major        enum_discriminants_undefined_non_unit_variant
        PASS [   0.000s]       major        enum_marked_non_exhaustive
        PASS [   0.000s]       major        enum_missing
        PASS [   0.002s]       minor        enum_must_use_added
        PASS [   0.000s]       major        enum_no_repr_variant_discriminant_changed
        PASS [   0.000s]       major        enum_now_doc_hidden
        PASS [   0.002s]       major        enum_repr_int_changed
        PASS [   0.002s]       major        enum_repr_int_removed
        PASS [   0.002s]       major        enum_repr_transparent_removed
        PASS [   0.001s]       major        enum_repr_variant_discriminant_changed
        PASS [   0.001s]       major        enum_struct_variant_field_added
        PASS [   0.001s]       major        enum_struct_variant_field_missing
        PASS [   0.000s]       major        enum_struct_variant_field_now_doc_hidden
        PASS [   0.000s]       major        enum_tuple_variant_changed_kind
        PASS [   0.000s]       major        enum_tuple_variant_field_added
        PASS [   0.000s]       major        enum_tuple_variant_field_missing
        PASS [   0.001s]       major        enum_tuple_variant_field_now_doc_hidden
        PASS [   0.002s]       major        enum_unit_variant_changed_kind
        PASS [   0.000s]       major        enum_variant_added
        PASS [   0.000s]       major        enum_variant_marked_non_exhaustive
        PASS [   0.000s]       major        enum_variant_missing
        PASS [   0.000s]       major        exported_function_changed_abi
        PASS [   0.003s]       major        feature_missing
        PASS [   0.001s]       major        feature_not_enabled_by_default
        PASS [   0.000s]       major        function_abi_no_longer_unwind
        PASS [   0.003s]       major        function_abi_now_unwind
        PASS [   0.000s]       major        function_changed_abi
        PASS [   0.002s]       major        function_const_removed
        PASS [   0.000s]       major        function_export_name_changed
        PASS [   0.000s]       major        function_like_proc_macro_missing
        PASS [   0.000s]       minor        function_marked_deprecated
        PASS [   0.000s]       major        function_missing
        PASS [   0.000s]       minor        function_must_use_added
        PASS [   0.000s]       major        function_now_doc_hidden
        PASS [   0.000s]       major        function_parameter_count_changed
        PASS [   0.000s]       major        function_requires_different_const_generic_params
        PASS [   0.001s]       major        function_requires_different_generic_type_params
        PASS [   0.000s]       major        function_unsafe_added
        PASS [   0.000s]       minor        global_value_marked_deprecated
        PASS [   0.001s]       major        inherent_associated_const_now_doc_hidden
        PASS [   0.000s]       major        inherent_associated_pub_const_missing
        PASS [   0.000s]       major        inherent_method_const_removed
        PASS [   0.000s]       major        inherent_method_missing
        PASS [   0.000s]       minor        inherent_method_must_use_added
        PASS [   0.000s]       major        inherent_method_now_doc_hidden
        PASS [   0.001s]       major        inherent_method_unsafe_added
        PASS [   0.000s]       minor        macro_marked_deprecated
        PASS [   0.000s]       major        macro_no_longer_exported
        PASS [   0.000s]       major        macro_now_doc_hidden
        PASS [   0.001s]       major        method_parameter_count_changed
        PASS [   0.001s]       major        method_requires_different_const_generic_params
        PASS [   0.001s]       major        method_requires_different_generic_type_params
        PASS [   0.000s]       major        module_missing
        PASS [   0.000s]       major        non_exhaustive_struct_changed_type
        PASS [   0.000s]       major        partial_ord_enum_struct_variant_fields_reordered
        PASS [   0.001s]       major        partial_ord_enum_variants_reordered
        PASS [   0.000s]       major        partial_ord_struct_fields_reordered
        PASS [   0.000s]       minor        proc_macro_marked_deprecated
        PASS [   0.000s]       major        proc_macro_now_doc_hidden
        WARN [   0.001s]     always-run     pub_api_sealed_trait_became_unconditionally_sealed
        PASS [   0.000s]       minor        pub_api_sealed_trait_became_unsealed
        PASS [   0.000s]       major        pub_module_level_const_missing
        PASS [   0.000s]       major        pub_module_level_const_now_doc_hidden
        PASS [   0.000s]       major        pub_static_missing
        PASS [   0.003s]       major        pub_static_mut_now_immutable
        PASS [   0.000s]       major        pub_static_now_doc_hidden
        PASS [   0.000s]       major        pub_static_now_mutable
        PASS [   0.000s]       major        repr_c_enum_struct_variant_fields_reordered
        PASS [   0.000s]       major        repr_c_plain_struct_fields_reordered
        PASS [   0.000s]       major        repr_c_removed
        PASS [   0.001s]       major        repr_packed_added
        PASS [   0.001s]       major        repr_packed_removed
        PASS [   0.001s]       major        sized_impl_removed
        PASS [   0.000s]       major        static_became_unsafe
        PASS [   0.000s]       minor        struct_field_marked_deprecated
        PASS [   0.000s]       major        struct_marked_non_exhaustive
        PASS [   0.000s]       major        struct_missing
        PASS [   0.000s]       minor        struct_must_use_added
        PASS [   0.000s]       major        struct_now_doc_hidden
        PASS [   0.000s]       major        struct_pub_field_missing
        PASS [   0.000s]       major        struct_pub_field_now_doc_hidden
        PASS [   0.000s]       major        struct_repr_transparent_removed
        PASS [   0.002s]       major        struct_with_no_pub_fields_changed_type
        PASS [   0.000s]       major        struct_with_pub_fields_changed_type
        PASS [   0.001s]       major        trait_added_supertrait
        PASS [   0.000s]       major        trait_allows_fewer_const_generic_params
        PASS [   0.000s]       major        trait_allows_fewer_generic_type_params
        PASS [   0.000s]       major        trait_associated_const_added
        PASS [   0.000s]       major        trait_associated_const_default_removed
        PASS [   0.001s]       minor        trait_associated_const_marked_deprecated
        PASS [   0.001s]       major        trait_associated_const_now_doc_hidden
        PASS [   0.000s]       major        trait_associated_type_added
        PASS [   0.000s]       major        trait_associated_type_default_removed
        PASS [   0.000s]       minor        trait_associated_type_marked_deprecated
        PASS [   0.000s]       major        trait_associated_type_now_doc_hidden
        PASS [   0.000s]       minor        trait_marked_deprecated
        PASS [   0.000s]       major        trait_method_added
        PASS [   0.000s]       major        trait_method_default_impl_removed
        PASS [   0.000s]       minor        trait_method_marked_deprecated
        PASS [   0.000s]       major        trait_method_missing
        PASS [   0.000s]       major        trait_method_now_doc_hidden
        PASS [   0.003s]       major        trait_method_parameter_count_changed
        PASS [   0.001s]       major        trait_method_requires_different_const_generic_params
        PASS [   0.000s]       major        trait_method_requires_different_generic_type_params
        PASS [   0.000s]       major        trait_method_unsafe_added
        PASS [   0.000s]       major        trait_method_unsafe_removed
        PASS [   0.000s]       major        trait_mismatched_generic_lifetimes
        PASS [   0.000s]       major        trait_missing
        PASS [   0.000s]       minor        trait_must_use_added
        PASS [   0.000s]       major        trait_newly_sealed
        PASS [   0.000s]       major        trait_no_longer_dyn_compatible
        PASS [   0.000s]       major        trait_now_doc_hidden
        PASS [   0.000s]       major        trait_removed_associated_constant
        PASS [   0.000s]       major        trait_removed_associated_type
        PASS [   0.000s]       major        trait_removed_supertrait
        PASS [   0.000s]       major        trait_requires_more_const_generic_params
        PASS [   0.000s]       major        trait_requires_more_generic_type_params
        PASS [   0.000s]       major        trait_unsafe_added
        PASS [   0.000s]       major        trait_unsafe_removed
        PASS [   0.000s]       major        tuple_struct_to_plain_struct
        PASS [   0.000s]       major        type_allows_fewer_const_generic_params
        PASS [   0.000s]       major        type_allows_fewer_generic_type_params
        PASS [   0.000s]       minor        type_associated_const_marked_deprecated
        PASS [   0.000s]       minor        type_marked_deprecated
        PASS [   0.000s]       minor        type_method_marked_deprecated
        PASS [   0.000s]       major        type_mismatched_generic_lifetimes
        PASS [   0.000s]       major        type_requires_more_const_generic_params
        PASS [   0.000s]       major        type_requires_more_generic_type_params
        PASS [   0.000s]       minor        unconditionally_sealed_trait_became_pub_api_sealed
        PASS [   0.001s]       minor        unconditionally_sealed_trait_became_unsealed
        PASS [   0.000s]       major        union_field_added_with_all_pub_fields
        PASS [   0.000s]       major        union_field_added_with_non_pub_fields
        PASS [   0.000s]       major        union_field_missing
        PASS [   0.000s]       major        union_missing
        PASS [   0.000s]       minor        union_must_use_added
        PASS [   0.000s]       major        union_now_doc_hidden
        PASS [   0.000s]       major        union_pub_field_now_doc_hidden
        PASS [   0.000s]       major        unit_struct_changed_kind
     Checked [   0.012s] 148 checks: 147 pass, 0 fail, 1 warn, 0 skip

--- risk warning pub_api_sealed_trait_became_unconditionally_sealed: public API sealed trait became unconditionally sealed ---

Description:
A public API sealed trait has become unconditionally sealed, blocking all downstream implementations including those from first-party crates that rely on the non-public API.
        ref: https://rust-lang.github.io/api-guidelines/future-proofing.html#sealed-traits-protect-against-downstream-implementations-c-sealed
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/pub_api_sealed_trait_became_unconditionally_sealed.ron

Failed in:
  trait pub_api_sealed_trait_became_unconditionally_sealed::public_api_sealed_to_unconditionally_sealed::TraitExtendsUnconditionallyHiddenTrait in file /Users/frankmac/projects/rs/cargo-semver-checks/test_crates/pub_api_sealed_trait_became_unconditionally_sealed/new/src/lib.rs:8
  trait pub_api_sealed_trait_became_unconditionally_sealed::public_api_sealed_to_unconditionally_sealed::MethodReturningUnconditionallyHiddenToken in file /Users/frankmac/projects/rs/cargo-semver-checks/test_crates/pub_api_sealed_trait_became_unconditionally_sealed/new/src/lib.rs:10
  trait pub_api_sealed_trait_became_unconditionally_sealed::public_api_sealed_to_unconditionally_sealed::HiddenSealedWithWhereSelfBound in file /Users/frankmac/projects/rs/cargo-semver-checks/test_crates/pub_api_sealed_trait_became_unconditionally_sealed/new/src/lib.rs:18
  trait pub_api_sealed_trait_became_unconditionally_sealed::public_api_sealed_to_unconditionally_sealed::MethodTakingUnconditionallyHiddenToken in file /Users/frankmac/projects/rs/cargo-semver-checks/test_crates/pub_api_sealed_trait_became_unconditionally_sealed/new/src/lib.rs:14

 Risk Notice 1 potentially risky changes detected that require attention regardless of version bump
    Finished [   0.667s] pub_api_sealed_trait_became_unconditionally_sealed

Todo:

  • add test for override config
  • add test for meta-table override
  • add test to test-crate manifest_tests ?
  • new cli run mode
  • cli list type fix

@obi1kenobi
Copy link
Owner

Thanks for putting this together! I had a quick glance and it looks really promising!

I'm currently handling a couple of time-sensitive issues around rustdoc JSON that affect our ability to make the next release of cargo-semver-checks, so I temporarily don't have the cycles to review it in the depth this PR deserves. But I'm thrilled you've put it together, and I'm hoping that those issues are resolved quickly so I can jump back to this.

@Frank-III Frank-III closed this Mar 10, 2025
@Frank-III
Copy link
Contributor Author

close note: in favour of lint group

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants